/*
 *  Copyright 2008-2010 www.jrails.org
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package org.rails.extjs.panel.grid;

import org.rails.extjs.Observable;

public class GridView extends Observable {

	public GridView() {
		super();
	}
	
	public void setAutoFill(Boolean autoFill){
		setAutoFill(autoFill);
	}
	
	public Boolean isAutoFill(){
		return getBoolean("autoFill", false);
	}
	
	public void setCellSelector(String cellSelector){
		addOption("cellSelector",cellSelector);
	}
	
	public String getCellSelector(){
		return getString("cellSelector","td.x-grid3-cell");
	}
	
	public void setCellSelectorDepth(Integer cellSelectorDepth){
		addOption("cellSelectorDepth",cellSelectorDepth);
	}
	
	public Integer getCellSelectorDepth(){
		return getInteger("cellSelectorDepth",4);
	}
	
	public void setColumnsText(String columnsText){
		addOption("columnsText", columnsText);
	}
	
	public String getColumnsText(){
		return getString("columnsText", "Columns");
	}
	
	public void setDeferEmptyText(Boolean deferEmptyText){
		addOption("deferEmptyText", deferEmptyText);
	}
	
	public Boolean isDeferEmptyText(){
		return getBoolean("deferEmptyText", true);
	}
	
	public void setEmptyText(String emptyText){
		addOption("emptyText", emptyText);
	}
	
	public String getEmptyText(){
		return getString("emptyText", "");
	}
	
	public void setEnableRowBody(Boolean enableRowBody){
		addOption("enableRowBody",enableRowBody);
	}
	
	public Boolean isEnableRowBody(){
		return getBoolean("enableRowBody",true);
	}
	
	public void setForceFit(Boolean forceFit){
		addOption("forceFit", forceFit);
	}
	
	public Boolean isForceFit(){
		return getBoolean("forceFit", false);
	}
	
	public void setHeadersDisabled(Boolean headersDisabled){
		addOption("headersDisabled", headersDisabled);
	}
	
	public Boolean isHeadersDisabled(){
		return getBoolean("headersDisabled", false);
	}
	
	public void setRowSelector(String rowSelector){
		addOption("rowSelector", rowSelector);
	}

	public String getRowSelector(){
		return getString("rowSelector", "div.x-grid3-row");
	}
	
	public void setRowSelectorDepth(Integer rowSelectorDepth){
		addOption("rowSelectorDepth", rowSelectorDepth);
	}
	
	public Integer getRowSelectorDepth(){
		return getInteger("rowSelectorDepth", 10);
	}
	
	public void setScrollOffset(Integer scrollOffset){
		addOption("scrollOffset", scrollOffset);
	}
	
	public Integer getScrollOffset(){
		return getInteger("scrollOffset", 0);
	}
	
	public void setSelectedRowClass(String selectedRowClass){
		addOption("selectedRowClass", selectedRowClass);
	}
	
	public String getSelectedRowClass(){
		return getString("selectedRowClass", "x-grid3-row-selected");
	}
	
	public void setSortAscText(String sortAscText){
		addOption("sortAscText", sortAscText);
	}
	
	public String getSortAscText(){
		return getString("sortAscText", "Sort Ascending");
	}
	
	public void setSortDescText(String sortDescText){
		addOption("sortDescText", sortDescText);
	}
	
	public String getSortDescText(){
		return getString("sortDescText", "Sort Descending");
	}
	
	@Override
	public String getScript() {
		createItems();
		script = new StringBuffer("");
		script.append("new Ext.grid.GridView(");
		script.append(createOptions());
		script.append(")");
		return script.toString();
	}	

}
